import Vue from 'vue'
import Vuex from 'vuex'
import api from '../http/api'
import subjects from './modules/subjects.js'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        count: 0,
        userInfo: {}
        // subjectsData: []
    },
    mutations: {
        addone(state) {
            state.count++;
        },
        inputchange(state, num) {
            state.count = num;
        },
        SET_USERINFO(state, payload) {
            state.userInfo = payload;
        }
        // SET_SUBJECTS(state, payload) {
        //     state.subjectsData = payload;
        // }
    },
    actions: {
        // async getSubjectAsync(context) {
        //     const { data } = await api.subjects.getSubjects();
        //     console.log(data.data.rows);
        //     context.commit('SET_SUBJECTS', data.data.rows);
        // }
    },
    modules: {
        //注册模块
        subjects, //subjects: subjects 的简写
    }
})